#include <iostream>
#include <fstream>
#include<unistd.h>
#include <string>
#include <map>
#include <math.h>
#include<vector>
using namespace  std;
class test
{
private:
    std::string* str;

public:
    test()
    {
        str = new std::string();
    }
    ~test()
    {
        delete str;
    }
    std::string* getstr()
    {
        return str;
    }
    void write()
    {
        str->assign("string");
    }
};


void ts(std::string *& str)
{
    std::cout << "str " << str<< std::endl;
    test m_test;
    m_test.write();
    str = m_test.getstr();
    std::cout << "str " << str<< std::endl;
    std::cout << "str " << m_test.getstr()<< std::endl;
}
class inherit{
public:
    int setA(int b)
    {
        a = b;
    }
    virtual int getA(){
        int a = 66;
        return this->a;
    }
private:
    int a = 9;
};
class son : public inherit{
public:
//    int setA(int b)
//    {
//        a = b;
//    }
    int getA()
    {
        return a;
    }
    int getC()
    {return c;}
private:
    int a = 6;
    int c = 4;
};
class casttest{
public:
    casttest(int a, int b, int c){

        m_c = c;
    }

    int m_c;
};
vector<int> getvector(vector<int> a)
{
    return vector<int>(a);
}
int main() {
    vector<int> sad(5,1);
    string s="abcdefg";
    std::cout<<s[0]<<std::endl;
    s = string(s, 1);
    string str("02:55");
    string buff(str,0,2);
    buff = string(str, 3, 2);
    int a = atoi(buff.c_str());
    int b = 1;
    map<int,int> map2;
    map2[5];
    map2[4] = 5;
    int c = sqrt(2 * 5);
    cout<<c<<endl;


    /*casttest* A = new casttest(1,2 ,3);
    long long la = 0x12345678abcdLL;
    int ddd = 4;
    cout<<hex<<la<<endl;
    int* c;
    c = reinterpret_cast<int*>(&ddd);
    *c = 5;
    long long d = reinterpret_cast<long long>(c);
    A = reinterpret_cast<casttest*>(la);
    long long b = reinterpret_cast<long long>(A);
    cout<<d + c<<endl;
    int dd = 5;*/
//    inherit *o_son = new son;
//    son *o_son2 = new son;
//    o_son->setA(5);
//    cout<<o_son->inherit::getA()<<endl;
//    test m_test;
//    m_test.write();
//    std::string* newstr;
//    ts(newstr);
//    std::cout << "str " << *newstr<< std::endl;
//    return 0;
//    ifstream infile("ball.obj",ios::in);
//    if(!infile.is_open())
//    {
//        cout<<"no"<<endl;
//    }
//    string buff;
//    while(getline(infile,buff))
//    {
//        cout<<buff;
//    }
//    infile.close();
//    std::ofstream outfile("data/head_position.csv",std::ofstream::out | std::ios_base::app);
//    outfile.open("test1",ios::out);
//    outfile<<"aba";
//    outfile.close();
//    std::string s("test");
//    s = std::string(s, 2);
//
//        std::cout << "str " << s<< std::endl;
//        while(1);

        /*printf("还没执行fork函数时的本进程为：%d\n",getpid());
        int a;
        int b;
        int c;
        cout<<&a<<" "<<&b<<" "<<&c;
        pid_t ret=fork();//其返回值类型是pid_t型的
        int d;
        int e;
        sleep(1);
        if(ret>0)//父进程返回的是子进程ID
        {
            while(1)
            {
//                int d;
//                int e;
                d = 5;
                cout<<"x"<< &d<<" "<<&e<<" "<<d;
                printf("----------------------------------------------------\n");
                printf("父进程一直在运行\n");
                sleep(1);
            }
        }
        else if(ret==0)//子进程fork返回是0
        {
            int count=0;
            while(count<=10)
            {
                int f;
                int g;
                cout<<&d<<" "<<&e<<" "<<d;
                printf("子进程已经运行了%d秒\n",count+=1);
                sleep(1);
            }
            exit(0);//让子进程运行10s
        }
        else
            printf("进程创建失败\n");
         auto
        sleep(1);
        return 0;*/



}


